/**
* @file		DrawFlag.ixx
* @brief	旗子
*
*
* @version	1.0
* @author	lveyou
* @date		22-07-31
*
* @note
*/
export module DrawFlag;

import DND;
import ResMgr;
import Common;
import DefOrder;

//! 旗子
export class DrawFlag
{
public:
	DrawFlag();
	//设置样式
	void Set(string_view str, const Color& col)
	{
		_txt->SetString(str);
		_txt->SetColor(col);
		_txt->SetCenter();
	}

	void Render()
	{
		_sprFlag->Render();
		_sprBg->Render();
		_txt->Render();
	}

	bool IsPickup()
	{
		return _sprFlag->IsPickup();
	}

	Coor* GetCoor() { return _coor; }

	~DrawFlag()
	{
		delete _coor;
	}
private:
	Coor* _coor;
	gcSprite _sprFlag;//旗子
	gcSprite _sprBg;//文本背景
	gcText _txt;//文本
};


module: private;


DrawFlag::DrawFlag()
{
	_coor = Coor::Create();

	_sprFlag = g_factory->CreateSprite("flag");
	_sprFlag->SetQuad(createQuad(Size{ 64, 40 }));
	_sprFlag->SetCoor(_coor);
	_sprFlag->SetOrder(DefOrder::MAP_UI);

	_sprBg = g_factory->CreateSpriteDefault();
	_sprBg->SetQuad(createQuad(Size{ 45, 25 }));
	_sprBg->SetCoor(_coor);
	_sprBg->SetOrder(Math::OffsetOrder(DefOrder::MAP_UI, -1));

	_txt = g_res->CreateTextFlag();
	_txt->GetCoor()->SetParent(_coor); 
	_txt->SetOrder(Math::OffsetOrder(DefOrder::MAP_UI, -2));
}